// 函数的柯里化

function curry(fn){
    return function curried(...args){
        if(args.length === fn.length){
            return fn.apply(null, args)
        }else{
            return function(...args2){
                return curried.apply(null, args.concat(args2))
            }
        }
    }
}

const sum = curry(function(a,b,c,d){
    return a + b + c + d
})

console.log(sum(2,3,4,5,6))
console.log(sum(2)(3)(4)(5))